Print the names of the link modules associated with an object

I have a link module "A"
When I loop through the link in obj->"A" I can't get into the loop.
Before the loop I want to print all the link modules associated with obj (ingoing and outgoing links). How would I do this?

Thanks in advance.
lsand - Thu Nov 18 20:12:03 EST 2010

Re: Print the names of the link modules associated with an object
SystemAdmin - Fri Nov 19 03:00:40 EST 2010

You can use function "module" to get the link module handle either from a link or from a link reference:
 

Object o = current
LinkRef lr = null
Link l = null
 
for lr in o <- "*" do
   {
     print "in: " fullName(module(lr)) "\n"
   }
   
for l in o -> "*" do
   {
     print "out: " fullName(module(l)) "\n"
   }

Re: Print the names of the link modules associated with an object
lsand - Fri Nov 19 12:44:18 EST 2010

SystemAdmin - Fri Nov 19 03:00:40 EST 2010

You can use function "module" to get the link module handle either from a link or from a link reference:
 

Object o = current
LinkRef lr = null
Link l = null
 
for lr in o <- "*" do
   {
     print "in: " fullName(module(lr)) "\n"
   }
   
for l in o -> "*" do
   {
     print "out: " fullName(module(l)) "\n"
   }

thanks!

Re: Print the names of the link modules associated with an object
llandale - Fri Nov 19 13:29:39 EST 2010

I never had luck with the "for lnk in obj->NameLinkMod loop". I believe that it will find NameLinkMod only if its a fully qualified name like "/MyProject/MyLinkFolder/MyLinkModule", or if its unqualified like "MyLinkModule" then it must be in the 'current' folder, or if its a partially qualified name like MyLinkFolder/MyLinkModule" when the current folder is the top project. The problem being, of course, where is the 'current folder' when running the script? No, gets too messy for me. It seems to me that the script would probably want to find any link in a module named "MyLinkModule" and it doesn't care where it is; or specifically in which project it resides.

I routinely use "*" in the loop and THEN check for the name of the link module, like this:

string NameLinkMod  = "MyLinkModule"
Link  lnk
Module mLink
for lnk in obj->"*" do
{  mLink = module(lnk)
   if (null mLink or name(mLink) != NameLinkMod) continue // wrong kind of link
         // Deal with this link I care about
}

 

  • Louie


Well, actually I wrote this rediculously clever "does link module match" function that will let me check the name against perhaps a "Requirements" string, which will match any link module with the name 'Requirements' in it anywhere. Very clever. Never used it, I just send the complete base name of the link module since the number of different link relationships is pretty small (less than 10) and its easy just to decide and code which link modules I care about.